package com.heima.user.controller.v1;

import com.heima.model.common.dtos.ResponseResult;

import com.heima.model.user.dtos.RegisterDto;
import com.heima.model.user.dtos.UserDto;
import com.heima.user.service.ApUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/api/v1/register")
public class UserRegisterController {
    //注入
    @Autowired
    private ApUserService userService;

    /**
     * 发送验证码
     * @param registerDto
     * @param session
     * @return
     */
    @PostMapping("/sendMsg")
    public ResponseResult sendMsg(@RequestBody RegisterDto registerDto, HttpSession session){
        //调用方法
        return userService.sendMsg(registerDto,session);
    }

    /**
     * 注册
     * @param registerDto
     * @return
     */
    @PostMapping("/register_auth")
    public ResponseResult register(@RequestBody RegisterDto registerDto, HttpSession session){
        //调用方法
        return userService.register(registerDto,session);
    }

    @PostMapping("/saveUser")
    public ResponseResult saveUser(@RequestBody UserDto userDto, HttpSession session){
        //调用方法
        return userService.saveUser(userDto,session);
    }


}
